import React, { Component } from 'react';

class View extends Component {
    constructor(props){
        super(props);
        this.state = {
            sClass:'jiaoyu jh',
            edu:{
                name:''
            },
            edus:[]
        }
    }

    addFn(e,sCls){
        const obj = {
            name:'1'
        }
        e.preventDefault();
        this.setState({
            sClass:sCls,
            edus:[...this.state.edus,obj]
        })
        // this.state.edus.push(obj)
        this.setState((state,props)=>({
            edus:[...state.edus,obj]
        }))
    }
    render(){
        console.log(this.state.edus)
        return(
            <div className={this.state.sClass}>
                <h2 className="clearfix"><a onClick={(e)=>this.addFn(e,'jiaoyu bd')} href="true">添加</a>教育培训</h2>
                <div className="jiahao">
                    <h3 onClick={(e)=>this.addFn(e,'jiaoyu bd')}>这是首次未添加时的大加号</h3>
                </div>
                <div className="biaodan">
                    <h3>这是添加或编辑时的表单</h3>
                    <input type="button" onClick={(e)=>this.addFn(e,'jiaoyu xs')} value="保存"/>
                </div>
                <div className="xianshi">
                    <h3>这是表单界面保存后显示的模块</h3>
                    <input type="button" onClick={(e)=>this.addFn(e,'jiaoyu bd')} value="修改"/>
                </div>
            </div>
        )
    }
}

export default View;
